<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Utilities
 *
 * @author Kenny
 */
class Utilities {
    const STATUS_LOCK = 'LCK';
    const STATUS_BOOKED = 'BKD';
    const STATUS_CHECKED = 'CHK';
    const STATUS_AMENDED = 'AMD';
    const STATUS_PAID = 'PAD';
    const STATUS_UNPAID = 'UPD';
    const STATUS_CANCEL = 'CCL';
    
    public static function random_string() {
        $character_set_array = array();
        $character_set_array[] = array('count' => 4, 'characters' => 'abcdefghijklmnopqrstuvwxyz');
        $character_set_array[] = array('count' => 2, 'characters' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ');
        $character_set_array[] = array('count' => 2, 'characters' => '0123456789');

        $temp_array = array();
        foreach ($character_set_array as $character_set) {
            for ($i = 0; $i < $character_set['count']; $i++) {
                $temp_array[] = $character_set['characters'][rand(0, strlen($character_set['characters']) - 1)];
            }
        }
        shuffle($temp_array);
        return implode('', $temp_array);
    }

    public static function calculateTime($departuredate, $departuretime, $traveltime) {
        $datearray = explode('-', $departuredate);
        $deptarray = explode(':', $departuretime);
        $travalarray = explode(':', $traveltime);
        $dept = mktime($deptarray[0], $deptarray[1], $deptarray[2], $datearray[1], $datearray[2], $datearray[0]);
        $travel = $travalarray[0] * 60 * 60 + $travalarray[1] * 60 + $travalarray[2];
        $dept += $travel;
        return $dept;
    }
}
?>
